import React, { useState, useEffect } from 'react';
import { info_update } from 'use/info';
import { ColorTitle } from 'base/ctl/title';
import { g_db } from 'db/state';
import { IkFind, IkSelect, ck_int, ck_empty, obj_int, IkInput, useForm, obj_empty, for_obj, uReal, is_empty,
    uJob, obj_str, ErrView, box_tp, uDb, cline, Wait, Input, NuiDlg, NuiBt } from 'sui';

const lst_yn = [
    {id: "Y", des: "双面"},
    {id: "S", des: "单面"},
    {id: "N", des: "无"},
];

const lst_mfc = [
    {id: "Y", des: "有"},
    {id: "N", des: "无"},
];

const lst_qyd= [
    {id: "Y", des: "是"},
    {id: "N", des: "否"},
];

const tag_seal = () => {
    const v = g_db.seal();
    if (v === "Y") {
        return "2RZ";
    }

    if (v === "S") {
        return "RZ";
    }

    return "";
};

const ck_space = (v, pre) => {
    if (!v) {
        return pre + "不能为空";
    }

    const tmp = parseInt(v, 10);
    if (isNaN(tmp)) {
        return pre + "必须为数字";
    }

    if (tmp <= 0) {
        return pre + "必须大于0";
    }
};

const DlgBox = ({ umd, open, setOpen }) => {
    const [cur, setCur] = useState();
    const [err, setErr] = useState();
    const [tray, setTray] = useState();
    const [level, setLevel] = useState();
    const [wait, setWait] = useState(false);

    useEffect(() => {
        if (!open) {
            return;
        }

        setCur(null);
        setErr("");

        const v_tray = g_db.boxtray();
        if (v_tray) {
            setTray("" + v_tray);
        } else {
            setTray("");
        }

        const v_level = g_db.boxlv();
        if (v_level) {
            setLevel("" + v_level);
        } else {
            setLevel("");
        }

    }, [open]);

    const herr = (e) => {
        setErr(e);
        setWait(false);
    };

    const hdone = () => {
        setWait(true);

        let e = ck_space(tray, "托盘规格");
        if (e) {
            return herr(e);
        }

        e = ck_space(level, "托盘层数");
        if (e) {
            return herr(e);
        }

        if (cur !== "outer" && cur !== "inner") {
            return herr("请选择内外圈类型");
        }

        const tp = g_db.boxtp();

        if (tp && cur !== tp) {
            return herr(`内外圈类型不匹配, 箱子类型为: ${box_tp(tp)}, 选择的类型为: ${box_tp(cur)}`);
        }

        const box_sn = g_db.box();

        uDb(null, `file/md/box_${box_sn}`,
            {
                line: cline(),
                sn: "attr",
                v: {
                    tp: cur,
                    tray: tray,
                    level: level,
                }
            },
            r => {
                g_db.s_boxtray(parseInt(tray, 10));
                g_db.s_boxlv(parseInt(level, 10));
                g_db.s_boxtp(cur);

                setWait(false);
                setOpen(false);

                umd.set_st("step_over");
            }, e => herr("设置料箱属性出错"));
    };

    const getName = () => {
        if (cur === "outer") {
            return "外圈";
        } else if (cur === "inner") {
            return "内圈";
        }

        return "无";
    };

    return (
        <NuiDlg open={open} title="选择类型" hcmd={hdone} labd="确定">
            <div className="flex flex-col">
                <div className="inline-flex items-center">
                    <div className="inline-flex items-center">
                        <div className="text-xl mr-8">当前选择</div>
                        <ColorTitle value={getName()} cl="orange"/>
                    </div>
                    <div className="inline-flex ml-6">
                        <NuiBt className="h-16 w-20" color="blue" hcmd={() => setCur("outer")}>外圈</NuiBt>
                        <NuiBt className="h-16 w-20 mx-8" color="green" hcmd={() => setCur("inner")}>内圈</NuiBt>
                    </div>
                </div>
                <Input label="托盘规格" value={tray} setValue={setTray} name="tray" className="mt-6"/>
                <Input label="托盘层数" value={level} setValue={setLevel} name="level"/>
            </div>
            <ErrView err={err}/>
            <Wait wait={wait}/>
        </NuiDlg>
    );
};

const DlgBoxSt = ({ umd, open, setOpen }) => {
    const [err, setErr] = useState();
    const [tray, setTray] = useState();
    const [level, setLevel] = useState();
    const [wait, setWait] = useState(false);

    useEffect(() => {
        if (!open) {
            return;
        }

        setErr("");

        const v_tray = g_db.boxtray();
        if (v_tray) {
            setTray("" + v_tray);
        } else {
            setTray("");
        }

        const v_level = g_db.boxlv();
        if (v_level) {
            setLevel("" + v_level);
        } else {
            setLevel("");
        }

    }, [open]);

    const herr = (e) => {
        setErr(e);
        setWait(false);
    };

    const hdone = () => {
        setWait(true);

        let e = ck_space(tray, "托盘规格");
        if (e) {
            return herr(e);
        }

        e = ck_space(level, "托盘层数");
        if (e) {
            return herr(e);
        }

        const box_sn = g_db.box();

        uDb(null, `file/md/box_${box_sn}`,
            {
                line: cline(),
                sn: "attr",
                v: {
                    tray: tray,
                    level: level,
                }
            },
            r => {
                g_db.s_boxtray(parseInt(tray, 10));
                g_db.s_boxlv(parseInt(level, 10));

                setWait(false);
                setOpen(false);

                umd.set_st("step_over");
            }, e => herr("设置料箱属性出错"));
    };

    return (
        <NuiDlg open={open} title="选择类型" hcmd={hdone} labd="确定">
            <div className="flex flex-col">
                <Input label="托盘规格" value={tray} setValue={setTray} name="tray" className="mt-6"/>
                <Input label="托盘层数" value={level} setValue={setLevel} name="level"/>
            </div>
            <ErrView err={err}/>
            <Wait wait={wait}/>
        </NuiDlg>
    );
};

const DlgBoxTp = ({ umd, open, setOpen }) => {
    const [cur, setCur] = useState();
    const [err, setErr] = useState();
    const [wait, setWait] = useState(false);

    useEffect(() => {
        if (!open) {
            return;
        }

        setCur(null);
        setErr("");
    }, [open]);

    const herr = (e) => {
        setErr(e);
        setWait(false);
    };

    const hdone = () => {
        setWait(true);

        if (cur !== "outer" && cur !== "inner") {
            return herr("请选择内外圈类型");
        }

        if (is_empty(umd.info)) {
            setWait(false);
            setOpen(false);
            umd.set_st("step_over");

            return;
        }

        g_db.s_boxtp(cur);

        uJob(null, "away/boxpsn",
            {
                line: cline(),
                tp: cur,
                box: g_db.box(),
            },
            r => {
                const tmp_v = {};

                umd.info.forEach(d => {
                    tmp_v[d.sn] = {};
                });

                r.forEach(d => {
                    const psn = obj_str(d, "sn");

                    const f = tmp_v[psn];
                    if (!f) {
                        return;
                    }

                    tmp_v[psn] = d;
                });

                info_update(umd, tmp_v);

                setWait(false);
                setOpen(false);
                umd.set_st("step_over");
            },
            e => {
                setWait(false);
                setOpen(false);
                umd.set_st("step_over");
            });
    };

    const getName = () => {
        if (cur === "outer") {
            return "外圈";
        } else if (cur === "inner") {
            return "内圈";
        }

        return "无";
    };

    return (
        <NuiDlg open={open} title="选择类型" hcmd={hdone} labd="确定">
            <div className="flex flex-col">
                <div className="inline-flex items-center">
                    <div className="inline-flex items-center">
                        <div className="text-xl mr-8">当前选择</div>
                        <ColorTitle value={getName()} cl="orange"/>
                    </div>
                    <div className="inline-flex ml-6">
                        <NuiBt className="h-16 w-20" color="blue" hcmd={() => setCur("outer")}>外圈</NuiBt>
                        <NuiBt className="h-16 w-20 mx-8" color="green" hcmd={() => setCur("inner")}>内圈</NuiBt>
                    </div>
                </div>
            </div>
            <ErrView err={err}/>
            <Wait wait={wait}/>
        </NuiDlg>
    );
};

const DlgBoxGood = ({ umd, open, setOpen, lst_lub }) => {
    const [err, setErr] = useState();
    const [wait, setWait] = useState(false);
    const [value, setValue] = useState();
    const form = useForm(setValue);

    useEffect(() => {
        if (!open) {
            return;
        }

        setErr("");

        const tmp = {
            yn: "N",
            lub: "252",
            tray: 24,
            level: 1,
        };

        const tray = g_db.boxtray();
        if (tray) {
            tmp["tray"] = tray;
        }

        const level = g_db.boxlv();
        if (level) {
            tmp["level"] = level;
        }

        const seal = g_db.seal();
        if (seal) {
            tmp["yn"] = seal;
        }

        const lub = g_db.lub();
        if (lub) {
            tmp["lub"] = lub;
        }

        setValue(tmp);
    }, [open]);

    const herr = (e) => {
        setErr(e);
        setWait(false);
    };

    const hdone = () => {
        const ck = {
            tray: v => ck_int(v, "托盘规格"),
            level: v => ck_int(v, "托盘层数"),
            lub: v => ck_empty(v, "润滑类型"),
            yn: v => ck_empty(v, "密封圈"),
        };

        if (!form.hcheck(ck, value)) {
            return;
        }

        setWait(true);

        const box_sn = g_db.box();

        const tray = obj_int(value, "tray");
        const level = obj_int(value, "level");
        const seal = obj_str(value, "yn");
        const lub = obj_str(value, "lub");

        uDb(null, `file/md/gbox_${box_sn}`,
            {
                line: cline(),
                sn: "attr",
                v: {
                    tray: tray,
                    level: level,
                    seal: seal,
                    lub: lub,
                }
            },
            r => {
                g_db.s_boxtray(tray);
                g_db.s_boxlv(level);
                g_db.s_seal(seal);
                g_db.s_lub(lub);

                setWait(false);
                setOpen(false);

                umd.set_st("step_over");
            }, e => herr("设置料箱属性出错"));
    };

    return (
        <NuiDlg open={open} title="设置箱子" hcmd={hdone} labd="确定">
            <div className="flex flex-col">
                <IkInput label="托盘规格" value={value} form={form} name="tray" className="mt-6"/>
                <IkInput label="托盘层数" value={value} form={form} name="level"/>
                <IkFind label="润滑类型" value={value} form={form} name="lub" lst={lst_lub}/>
                <IkSelect label="密封圈" value={value} form={form} name="yn" lst={lst_yn}/>
            </div>
            <ErrView err={err}/>
            <Wait wait={wait}/>
        </NuiDlg>
    );
};

const DlgAuto = ({ umd, open, setOpen }) => {
    const [cur, setCur] = useState();
    const [err, setErr] = useState();
    const [wait, setWait] = useState(false);

    useEffect(() => {
        if (!open) {
            return;
        }

        setCur(null);
        setErr("");
    }, [open]);

    const herr = (e) => {
        setErr(e);
        setWait(false);
    };

    const hdone = () => {
        setWait(true);

        if (cur !== "outer" && cur !== "inner") {
            return herr("请选择内外圈类型");
        }

        if (is_empty(umd.info)) {
            setWait(false);
            setOpen(false);
            umd.set_st("step_over");

            return;
        }

        g_db.s_boxtp(cur);

        uReal(null, "auto/restore",
            {
                line: cline(),
                k: g_db.box(),
                tp:  cur,
            },
            r => {
                let tmp = r.inner;
                if (obj_empty(tmp)) {
                    tmp = r.outer;
                }

                if (obj_empty(tmp)) {
                    setWait(false);
                    setOpen(false);
                    return;
                }

                const val = {};

                for_obj(tmp, (k, v) => {
                    for_obj(v, (tk, tv) => {
                        val[tk] = tv;
                    });
                });

                info_update(umd, val);

                setWait(false);
                setOpen(false);
            },
            e => {
                setWait(false);
                setOpen(false);
            }
        );
    };

    const getName = () => {
        if (cur === "outer") {
            return "外圈";
        } else if (cur === "inner") {
            return "内圈";
        }

        return "无";
    };

    return (
        <NuiDlg open={open} title="选择类型" hcmd={hdone} labd="确定">
            <div className="flex flex-col">
                <div className="inline-flex items-center">
                    <div className="inline-flex items-center">
                        <div className="text-xl mr-8">当前选择</div>
                        <ColorTitle value={getName()} cl="orange"/>
                    </div>
                    <div className="inline-flex ml-6">
                        <NuiBt className="h-16 w-20" color="blue" hcmd={() => setCur("outer")}>外圈</NuiBt>
                        <NuiBt className="h-16 w-20 mx-8" color="green" hcmd={() => setCur("inner")}>内圈</NuiBt>
                    </div>
                </div>
            </div>
            <ErrView err={err}/>
            <Wait wait={wait}/>
        </NuiDlg>
    );
};

const SelectBox = ({ umd, open, setOpen, tp }) => {
    const [err, setErr] = useState();
    const [tray, setTray] = useState();
    const [level, setLevel] = useState();
    const [wait, setWait] = useState(false);

    useEffect(() => {
        if (!open) {
            return;
        }

        setErr("");

        const v_tray = g_db.boxtray();
        if (v_tray) {
            setTray("" + v_tray);
        } else {
            setTray("");
        }

        const v_level = g_db.boxlv();
        if (v_level) {
            setLevel("" + v_level);
        } else {
            setLevel("");
        }
    }, [open]);

    const herr = (e) => {
        setErr(e);
        setWait(false);
    };

    const hdone = () => {
        setWait(true);

        let e = ck_space(tray, "托盘规格");
        if (e) {
            return herr(e);
        }

        e = ck_space(level, "托盘层数");
        if (e) {
            return herr(e);
        }

        const old = g_db.boxtp();

        if (old && old !== tp) {
            return herr(`类型不匹配, 要求箱子类型为: ${box_tp(tp)}, 扫码的类型为: ${box_tp(old)}`);
        }

        const box_sn = g_db.box();

        uDb(null, `file/md/box_${box_sn}`,
            {
                line: cline(),
                sn: "attr",
                v: {
                    tp: tp,
                    tray: tray,
                    level: level,
                }
            },
            r => {
                g_db.s_boxtray(parseInt(tray, 10));
                g_db.s_boxlv(parseInt(level, 10));
                g_db.s_boxtp(tp);

                setWait(false);
                setOpen(false);

                umd.set_st("step_over");
            }, e => herr("设置料箱属性出错"));
    };

    return (
        <NuiDlg open={open} title="设置规格" hcmd={hdone} labd="确定">
            <div className="flex flex-col">
                <Input label="托盘规格" value={tray} setValue={setTray} name="tray" className="mt-6"/>
                <Input label="托盘层数" value={level} setValue={setLevel} name="level"/>
            </div>
            <ErrView err={err}/>
            <Wait wait={wait}/>
        </NuiDlg>
    );
};

const BoxBad = ({ umd, open, setOpen, lst_tech }) => {
    const [err, setErr] = useState();
    const [tray, setTray] = useState();
    const [level, setLevel] = useState();
    const [wait, setWait] = useState(false);
    const [value, setValue] = useState();
    const form = useForm(setValue);

    useEffect(() => {
        if (!open) {
            return;
        }

        setErr("");

        const v_tray = g_db.boxtray();
        if (v_tray) {
            setTray("" + v_tray);
        } else {
            setTray("");
        }

        const v_level = g_db.boxlv();
        if (v_level) {
            setLevel("" + v_level);
        } else {
            setLevel("");
        }

    }, [open]);

    const herr = (e) => {
        setErr(e);
        setWait(false);
    };

    const hdone = () => {
        const ck = {
            tech: v => ck_empty(v, "工艺"),
        };

        if (!form.hcheck(ck, value)) {
            return;
        }

        setWait(true);

        let e = ck_space(tray, "托盘规格");
        if (e) {
            return herr(e);
        }

        e = ck_space(level, "托盘层数");
        if (e) {
            return herr(e);
        }

        const box_sn = g_db.box();

        uDb(null, `file/md/box_${box_sn}`,
            {
                line: cline(),
                sn: "attr",
                v: {
                    tray: tray,
                    level: level,
                }
            },
            r => {
                g_db.s_boxtray(parseInt(tray, 10));
                g_db.s_boxlv(parseInt(level, 10));
                g_db.s_tech(obj_str(value, "tech"));

                setWait(false);
                setOpen(false);

                umd.set_st("step_over");
            }, e => herr("设置料箱属性出错"));
    };

    return (
        <NuiDlg open={open} title="选择类型" hcmd={hdone} labd="确定">
            <div className="flex flex-col">
                <Input label="托盘规格" value={tray} setValue={setTray} name="tray" className="mt-6"/>
                <Input label="托盘层数" value={level} setValue={setLevel} name="level"/>
                <IkFind label="工艺" value={value} form={form} name="tech" lst={lst_tech}/>
            </div>
            <ErrView err={err}/>
            <Wait wait={wait}/>
        </NuiDlg>
    );
};

const DlgBad = ({ umd, open, setOpen }) => {
    const [wait, setWait] = useState(false);

    const hdone = () => {
        setWait(true);

        uJob(null, "work/lost",
            {
                line: cline(),
                k: g_db.box(),
            },
            r => {
                const val = {};

                r.forEach(d => {
                    val[d.sn] = d;
                })

                info_update(umd, val);

                setWait(false);
                setOpen(false);

                umd.set_st("step_over");
            },
            e => {
                setWait(false);
                setOpen(false);

                umd.set_st("step_over");
            }
        );
    };

    return (
        <NuiDlg open={open} title="统计" hcmd={hdone} labd="确定">
            <ErrView err="开始统计缺失数据" tp="info"/>
            <Wait wait={wait}/>
        </NuiDlg>
    );
};

const DlgTag = ({ umd, open, setOpen, lst_lub, map_tag }) => {
    const [err, setErr] = useState();
    const [value, setValue] = useState();
    const form = useForm(setValue);

    useEffect(() => {
        if (!open) {
            return;
        }

        setErr("");

        const tmp = {
            yn: "N",
            lub: "252",
        };

        const seal = g_db.seal();
        if (seal) {
            tmp["seal"] = seal;
        }

        const lub = g_db.lub();
        if (lub) {
            tmp["lub"] = lub;
        }

        setValue(tmp);
    }, [open]);

    const hdone = () => {
        const ck = {
            lub: v => ck_empty(v, "润滑类型"),
            yn: v => ck_empty(v, "密封圈"),
        };

        if (!form.hcheck(ck, value)) {
            return;
        }

        const seal = obj_str(value, "yn");
        const lub = obj_str(value, "lub");

        g_db.s_seal(seal);
        g_db.s_lub(lub);
        g_db.s_lub_tag("");

        if (map_tag) {
            const v = map_tag[lub];
            if (v) {
                g_db.s_lub_tag(v);
            }
        }

        let f = lst_yn.find(d => d.id === seal);
        if (f) {
            umd.set("seal", f.des);
        } else {
            umd.set("seal", seal);
        }

        f = lst_lub.find(d => d.id === lub);
        if (f) {
            umd.set("lub", f.name);
        } else {
            umd.set("lub", lub);
        }

        setOpen(false);
    };

    return (
        <NuiDlg open={open} title="选择类型" hcmd={hdone} labd="确定" hcancel={() => setOpen(false)}>
            <div className="flex flex-col">
                <IkFind label="润滑类型" value={value} form={form} name="lub" lst={lst_lub} className="ml-2"/>
                <IkSelect label="密封圈" value={value} form={form} name="yn" lst={lst_yn}/>
            </div>
            <ErrView err={err}/>
        </NuiDlg>
    );
};

const DlgOut = ({ umd, open, setOpen, lst_lub }) => {
    const [err, setErr] = useState();
    const [wait, setWait] = useState(false);
    const [value, setValue] = useState();
    const form = useForm(setValue);

    useEffect(() => {
        if (!open) {
            return;
        }

        setErr("");

        const tmp = {
            tray: 24,
            level: 1,
        };

        const tray = g_db.boxtray();
        if (tray) {
            tmp["tray"] = tray;
        }

        const level = g_db.boxlv();
        if (level) {
            tmp["level"] = level;
        }

        setValue(tmp);
    }, [open]);

    const herr = (e) => {
        setErr(e);
        setWait(false);
    };

    const hdone = () => {
        const ck = {
            tray: v => ck_int(v, "托盘规格"),
            level: v => ck_int(v, "托盘层数"),
        };

        if (!form.hcheck(ck, value)) {
            return;
        }

        setWait(true);

        const box_sn = g_db.box();

        const tray = obj_int(value, "tray");
        const level = obj_int(value, "level");

        uDb(null, `file/md/gbox_${box_sn}`,
            {
                line: cline(),
                sn: "attr",
                v: {
                    tray: tray,
                    level: level,
                }
            },
            r => {
                g_db.s_boxtray(tray);
                g_db.s_boxlv(level);

                setWait(false);
                setOpen(false);

                umd.set_st("step_over");
            }, e => herr("设置料箱属性出错"));
    };

    return (
        <NuiDlg open={open} title="设置箱子" hcmd={hdone} labd="确定">
            <div className="flex flex-col">
                <IkInput label="托盘规格" value={value} form={form} name="tray" className="mt-6"/>
                <IkInput label="托盘层数" value={value} form={form} name="level"/>
            </div>
            <ErrView err={err}/>
            <Wait wait={wait}/>
        </NuiDlg>
    );
};

const DlgGoodIn = ({ umd, open, setOpen, lst_lub }) => {
    const [err, setErr] = useState();
    const [wait, setWait] = useState(false);
    const [value, setValue] = useState();
    const form = useForm(setValue);

    useEffect(() => {
        if (!open) {
            return;
        }

        setErr("");

        const tmp = {
            yn: "N",
            mfc: "N",
            qyd: "N",
            lub: "252",
            tray: 48,
            level: 1,
        };

        const tray = g_db.boxtray();
        if (tray) {
            tmp["tray"] = tray;
        }

        const level = g_db.boxlv();
        if (level) {
            tmp["level"] = level;
        }

        const seal = g_db.seal();
        if (seal) {
            tmp["yn"] = seal;
        }

        const lub = g_db.lub();
        if (lub) {
            tmp["lub"] = lub;
        }

        const mfc = g_db.mfc();
        if (mfc) {
            tmp["mfc"] = mfc;
        }

        const qyd = g_db.qyd();
        if (qyd) {
            tmp["qyd"] = qyd;
        }

        setValue(tmp);
    }, [open]);

    const herr = (e) => {
        setErr(e);
        setWait(false);
    };

    const hdone = () => {
        const ck = {
            tray: v => ck_int(v, "托盘规格"),
            level: v => ck_int(v, "托盘层数"),
            lub: v => ck_empty(v, "润滑类型"),
            yn: v => ck_empty(v, "密封圈"),
            mfc: v => ck_empty(v, "密封圈"),
            qyd: v => ck_empty(v, "密封圈"),
        };

        if (!form.hcheck(ck, value)) {
            return;
        }

        setWait(true);

        const box_sn = g_db.box();

        const tray = obj_int(value, "tray");
        const level = obj_int(value, "level");
        const seal = obj_str(value, "yn");
        const lub = obj_str(value, "lub");
        const mfc = obj_str(value, "mfc");
        const qyd = obj_str(value, "qyd");

        uDb(null, `file/md/gbox_${box_sn}`,
            {
                line: cline(),
                sn: "attr",
                v: {
                    tray: tray,
                    level: level,
                    seal: seal,
                    lub: lub,
                    mfc: mfc,
                    qyd: qyd,
                }
            },
            r => {
                g_db.s_boxtray(tray);
                g_db.s_boxlv(level);
                g_db.s_seal(seal);
                g_db.s_lub(lub);
                g_db.s_mfc(mfc);
                g_db.s_qyd(qyd);

                setWait(false);
                setOpen(false);

                umd.set_st("step_over");
            }, e => herr("设置料箱属性出错"));
    };

    return (
        <NuiDlg open={open} title="设置箱子" hcmd={hdone} labd="确定">
            <div className="flex flex-col">
                <IkInput label="托盘规格" value={value} form={form} name="tray" className="mt-6"/>
                <IkInput label="托盘层数" value={value} form={form} name="level"/>
                <IkFind label="润滑类型" value={value} form={form} name="lub" lst={lst_lub}/>
                <IkSelect label="密封圈" value={value} form={form} name="yn" lst={lst_yn}/>
                <IkSelect label="密封槽" value={value} form={form} name="mfc" lst={lst_mfc}/>
                <IkSelect label="球引导" value={value} form={form} name="qyd" lst={lst_qyd}/>
            </div>
            <ErrView err={err}/>
            <Wait wait={wait}/>
        </NuiDlg>
    );
};

export {lst_qyd, lst_mfc,  DlgGoodIn, DlgOut, tag_seal, DlgTag, DlgBad, DlgBoxSt, SelectBox, DlgAuto, lst_yn, DlgBoxGood, DlgBoxTp, BoxBad, DlgBox};
